﻿#

param
(
	[String]$目的ip地址 = '192.168.123.45',
	$端口 = 22,
	$账户 = 'root',
	$ssh_key_文件路径 = "$env:USERPROFILE\.ssh\id_rsa"
)

$msg = @'
需要ssh.exe,低版本win请去这里下载：https://github.com/PowerShell/Win32-OpenSSH/releases
建议在Windows Terminal中使用：
"commandline" : "C:\\Program Files\\PowerShell\\7-preview\\pwsh.exe -noexit -file d:\\ps脚本\\centos7.ps1",
'@

Write-Warning $msg


if ($PSVersionTable.psversion.major -ge 6)
{
	Write-Host -ForegroundColor green "进入目的ip【$目的ip地址】"
	Enter-PSSession -Session (New-PSSession -HostName $目的ip地址 -Port $端口 -UserName root -KeyFilePath $ssh_key_文件路径)
}
else
{
	Write-Error '需要powershell版本v6。v7更好'
}
